package com.dnjn.mes.biz.modbus;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Profile({"test", "dev", "local"})
@Component
public class ModbusInit implements CommandLineRunner {
    @Autowired
    private ModbusSlaveHelper modbusSlaveHelper;

    @PostConstruct
    public void process() throws Exception {
//        AsyncManager.me().execute(ModbusSlaveHelper.startModbusSlave());
//        modbusSlaveHelper.startModbusSlave();
    }

    @Override
    public void run(String... args) throws Exception {
//        ModbusSlaveHelper modbusSlaveHelper = SpringUtils.getBean("modbusSlaveHelper");
        modbusSlaveHelper.startModbusSlave();
    }
}
